A conventional general image sensing/playback apparatus comprises a so-called input/output device which performs writing of data on a recording medium and reading of data from the recording medium to record a sensed image or play back a recorded image. The CPU of the apparatus performs control in a so-called multi-task fashion in which a plurality of processes are apparently simultaneously performed. If different tasks try to access the common input/output device during control in such a multi-task manner, one of the tasks which tries to gain access first exclusively uses the input/output device until the task ends its processing. Another task which tries to access the input/output device later performs input/output processing after the input/output device enters an idle state when the task having tried to gain access earlier ends input/output processing.
In a method of accessing an input/output device as described above, even if a task with high urgency demands access to an input/output device, the task needs to wait until another task already accessing the input/output device, if any, ends access to the input/output device. Accordingly, a process which the user wants to perform with priority may be forced to wait. To cope with this problem, there are proposed processing methods which allow a task with high urgency to perform processing for a common device with priority by, e.g., inserting a sleep into a task with a low priority level and skipping, without any processing, a task which is sleeping when its turn for processing comes, shortening one period for access to a common device, or the like (see, e.g., Japanese Patent Laid-Open No. 10-283204).
Japanese Patent Laid-Open No. 10-283204 describes that one access period and sleep period for each task are decided on the basis of its priority level. However, under such control, if no task with a high priority level demands access to a common device, and only tasks with a low priority level demand access to the common device, there may occur a period when all tasks are sleeping. In this case, since no task accesses the common device, the processing efficiency decreases.
Also, even when the access periods and sleep periods of a plurality of tasks at a certain point in time achieve high processing efficiency, the same access periods and sleep periods continue to be used even after any one of the plurality of tasks ends, for example. For this reason, if a task with a high priority level ends, there may occur a period when all of continuing tasks with a low priority level are sleeping, and the processing efficiency may decrease.
Moreover, if a task with a low priority level is added when a plurality of tasks are accessing a common device, there may be a case in which a period when all of tasks with a low priority level are sleeping does not occur, and the plurality of tasks may be performed simply in order for a set access period at a time, and the processing of a task with a high priority level may take a long time.